<template>
	<div>
		<Button type="primary" @click="addData">添加用户</Button>
		<Button @click="handleSelectAll(true)">设置全选</Button>
        <Button @click="handleSelectAll(false)">取消全选</Button>
        <Button @click="removeSelectAll">多选删除</Button>
		<Input v-model="filter.name">
	       
	        <Button slot="append" icon="ios-search" @click="search"></Button>
	   	</Input>		
		<Table :columns="columns1" :data="list" ref="selection" ></Table>
		<Page :total="filter.total" show-elevator show-total size="small" :page-size="2" show-sizer @on-change="changePage" @on-page-size-change="changeSize"></Page>
		<Modal
	        v-model="modal1"
	        title="普通的Modal对话框标题"
	        @on-ok="ok"
	        @on-cancel="cancel">
	        <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
		        <FormItem label="姓名" prop="name">
		            <Input v-model="formValidate.name" placeholder="请输入姓名"></Input>
		        </FormItem>
		        <FormItem label="密码" prop="password">
		            <Input v-model="formValidate.password" placeholder="请输入密码"></Input>
		        </FormItem>
		        <FormItem label="邮箱" prop="mail">
		            <Input v-model="formValidate.mail" placeholder="请输入邮箱"></Input>
		        </FormItem>
		        <FormItem label="选择日期">
		            <Row>
		                <Col span="11">
		                    <FormItem prop="date">
		                        <DatePicker type="date" placeholder="选择日期" v-model="formValidate.date"></DatePicker>
		                    </FormItem>
		                </Col>
		                <Col span="2" style="text-align: center">-</Col>
		                <Col span="11">
		                    <FormItem prop="time">
		                        <TimePicker type="time" placeholder="选择时间" v-model="formValidate.time"></TimePicker>
		                    </FormItem>
		                </Col>
		            </Row>
		        </FormItem>
		        <FormItem label="介绍" prop="desc">
		            <Input v-model="formValidate.desc" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请输入..."></Input>
		        </FormItem>
		        <FormItem>
		            <Button type="primary" @click="handleSubmit('formValidate')">提交</Button>
		            <Button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</Button>
		        </FormItem>
		    </Form>
	   </Modal>

	</div>
</template>

<script>
	
	import Base from '../../common/Base.js';
	
	
	export default {
		mixins:[Base],
        data () {
            return {
            	module1:'users',
	               	columns1: [
				  	{
	                    type: 'selection',
	                    width: 60,
	                    align: 'center',
	                },
	                {
	                    title: '姓名',
	                    key: 'name'
	                },
	                 {
	                    title: '密码',
	                    key: 'password'
	                },
	                 {
	                    title: '邮箱',
	                    key: 'mail'
	                },
	                 {
	                    title: '介绍',
	                    key: 'desc'
	                },
	                 {
	                    title: '时间',
	                    key: 'date'
	                },
	                
	                {
	                    title: '操作',
	                    key: 'action',
	                    fixed: 'right',
	                    width: 120,
	                    render: (h, params) => {
	                        return h('div', [
	                            h('Button', {
	                                props: {
	                                    type: 'text',
	                                    size: 'small'
	                                },
	                                on: {
	                                    click: () => {
	                                       this.show(params.row._id)
	                                    }
	                                }
	                            }, '查看'),
	                            h('Button', {
	                                props: {
	                                    type: 'text',
	                                    size: 'small'
	                                },
	                                on: {
	                                    click: () => {
	                                        this.editData(params.row._id)
	                                    }
	                                }
	                            }, '编辑'),
	                            h('Button', {
	                                props: {
	                                    type: 'text',
	                                    size: 'small'
	                                },
	                                on: {
	                                    click: () => {
	                                        this.removeData(params.row._id);
	                                    }
	                                }
	                            }, '删除'),
	                            h('Button', {
	                                props: {
	                                    type: 'text',
	                                    size: 'small'
	                                },
	                                on: {
	                                    click: () => {
	//                                          this.editData(params.row._id)
	                                    }
	                                }
	                            }, '添加')  
	                        ]);
	                    }
	                }
	            ],
	            formValidate: {
	                name: '',
	                password:'',
	                mail: '',
	                date: '',
	                time: '',
	                desc: ''
	            },
	            ruleValidate: {
	                name: [
	                    { required: true, message: '姓名不能为空', trigger: 'blur' }
	                ],
	                password: [
	                    { required: true, message: '密码不能为空', trigger: 'blur' }
	                ],
	                mail: [
	                    { required: true, message: '邮箱不能为空', trigger: 'blur' },
	                    { type: 'email', message: '邮箱格式不正确', trigger: 'blur' }
	                ],
	                date: [
	                    { required: true, type: 'date', message: '请选择日期', trigger: 'change' }
	                ],
	                time: [
	                    { required: true, type: 'date', message: '请选择时间', trigger: 'change' }
	                ],
	                desc: [
	                    { required: true, message: '请输入个人介绍', trigger: 'blur' },
	                    { type: 'string', min: 5, message: '介绍不能少于5字', trigger: 'blur' }
	                ]
	            }
            }
        }
       	
       
    }
	
</script>

<style>
</style>